#include "sbwindow.h"
#include "app.h"
#include <allegro5/allegro_image.h>
#include <iostream>
using namespace std;

ALLEGRO_DISPLAY* initAllegro();

int main(int argc, char *argv[]) {

     ALLEGRO_DISPLAY *pDisplay = initAllegro();
     App app;
     SbWindow window(&app, pDisplay);
     window.handleEvents();
     return 0;
}

ALLEGRO_DISPLAY* initAllegro() {

     // initialize allegro
     al_init();
     if (!al_init_image_addon()) {
	  cerr << "error initializing image io addon" << endl;
	  exit(1);
     }
     // create display
     al_set_new_display_flags(ALLEGRO_RESIZABLE|ALLEGRO_GENERATE_EXPOSE_EVENTS);
     ALLEGRO_DISPLAY *pDisplay = al_create_display(800, 600);
     if (!pDisplay) {
	  cerr << "error creating display" << endl;
	  exit(1);
     }
     // initialize keyboard
     if (!al_install_keyboard()) {
	  cerr << "error installing keyboard" << endl;
	  exit(1);
     }

     // init mouse
     if (!al_install_mouse()) {
	  cerr << "error installing mouse" << endl;
	  exit(1);
     }
     return pDisplay;
}
